<html><!-- Created using the cpp_pretty_printer from the dlib C++ library.  See http://dlib.net for updates. --><head><title>dlib C++ Library - xml_parser_kernel_interfaces.h</title></head><body bgcolor='white'><pre>
<font color='#009900'>// Copyright (C) 2003  Davis E. King (davis@dlib.net)
</font><font color='#009900'>// License: Boost Software License   See LICENSE.txt for the full license.
</font><font color='#0000FF'>#ifndef</font> DLIB_XML_PARSER_KERNEl_INTERFACES_
<font color='#0000FF'>#define</font> DLIB_XML_PARSER_KERNEl_INTERFACES_

<font color='#0000FF'>#include</font> <font color='#5555FF'>&lt;</font>string<font color='#5555FF'>&gt;</font>
<font color='#0000FF'>#include</font> "<a style='text-decoration:none' href='../interfaces/enumerable.h.html'>../interfaces/enumerable.h</a>"
<font color='#0000FF'>#include</font> "<a style='text-decoration:none' href='../interfaces/map_pair.h.html'>../interfaces/map_pair.h</a>"

<font color='#0000FF'>namespace</font> dlib
<b>{</b>

<font color='#009900'>// ----------------------------------------------------------------------------------------
</font><font color='#009900'>// ----------------------------------------------------------------------------------------
</font><font color='#009900'>// ----------------------------------------------------------------------------------------
</font>
    <font color='#0000FF'>class</font> <b><a name='attribute_list'></a>attribute_list</b> : <font color='#0000FF'>public</font> enumerable<font color='#5555FF'>&lt;</font>map_pair<font color='#5555FF'>&lt;</font>std::string,std::string<font color='#5555FF'>&gt;</font> <font color='#5555FF'>&gt;</font>
    <b>{</b>

        <font color='#009900'>/*!                
            WHAT THIS OBJECT REPRESENTS
                this object represents a list of the attributes found in
                an XML element.  each attribute is associated with a value.
        !*/</font>


    <font color='#0000FF'>public</font>:

        <font color='#0000FF'>inline</font> <font color='#0000FF'>virtual</font> ~<b><a name='attribute_list'></a>attribute_list</b> <font face='Lucida Console'>(</font>
        <font face='Lucida Console'>)</font> <font color='#5555FF'>=</font><font color='#979000'>0</font>;


        <font color='#0000FF'>virtual</font> <font color='#0000FF'><u>bool</u></font> <b><a name='is_in_list'></a>is_in_list</b> <font face='Lucida Console'>(</font>
            <font color='#0000FF'>const</font> std::string<font color='#5555FF'>&amp;</font> key
        <font face='Lucida Console'>)</font> <font color='#0000FF'>const</font> <font color='#5555FF'>=</font><font color='#979000'>0</font>;
        <font color='#009900'>/*!
            ensures
                - returns true if there is an attribute named key in the list 
                - returns false
        !*/</font>

        <font color='#0000FF'>virtual</font> <font color='#0000FF'>const</font> std::string<font color='#5555FF'>&amp;</font> <b><a name='operator'></a>operator</b>[] <font face='Lucida Console'>(</font>
            <font color='#0000FF'>const</font> std::string<font color='#5555FF'>&amp;</font> key
        <font face='Lucida Console'>)</font> <font color='#0000FF'>const</font> <font color='#5555FF'>=</font><font color='#979000'>0</font>;
        <font color='#009900'>/*!
            requires
                - is_in_list(key) == true
            ensures
                - returns a const reference to the value associated with the 
                  attribute named key.
        !*/</font>

    <font color='#0000FF'>protected</font>:

        <font color='#009900'>// restricted functions
</font>        attribute_list<font color='#5555FF'>&amp;</font> <b><a name='operator'></a>operator</b><font color='#5555FF'>=</font><font face='Lucida Console'>(</font>attribute_list<font color='#5555FF'>&amp;</font><font face='Lucida Console'>)</font> <b>{</b><font color='#0000FF'>return</font> <font color='#5555FF'>*</font><font color='#0000FF'>this</font>;<b>}</b>
    <b>}</b>;

<font color='#009900'>// ----------------------------------------------------------------------------------------
</font><font color='#009900'>// ----------------------------------------------------------------------------------------
</font><font color='#009900'>// ----------------------------------------------------------------------------------------
</font>
    <font color='#0000FF'>class</font> <b><a name='document_handler'></a>document_handler</b>
    <b>{</b>
        <font color='#009900'>/*!                
            EXCEPTIONS
                a document_handler is allowed to throw any exception


            WHAT THIS OBJECT REPRESENTS
                this object is an interface for handling the basic events
                generated by an XML parser
        !*/</font>


    <font color='#0000FF'>public</font>:

        <font color='#0000FF'>inline</font> <font color='#0000FF'>virtual</font> ~<b><a name='document_handler'></a>document_handler</b> <font face='Lucida Console'>(</font>
        <font face='Lucida Console'>)</font> <font color='#5555FF'>=</font><font color='#979000'>0</font>;

        <font color='#0000FF'>virtual</font> <font color='#0000FF'><u>void</u></font> <b><a name='start_document'></a>start_document</b> <font face='Lucida Console'>(</font>
        <font face='Lucida Console'>)</font><font color='#5555FF'>=</font><font color='#979000'>0</font>;
        <font color='#009900'>/*!
            requires
                - is called when the document parsing begins
        !*/</font>

        <font color='#0000FF'>virtual</font> <font color='#0000FF'><u>void</u></font> <b><a name='end_document'></a>end_document</b> <font face='Lucida Console'>(</font>
        <font face='Lucida Console'>)</font><font color='#5555FF'>=</font><font color='#979000'>0</font>;
        <font color='#009900'>/*!
            requires
                - is called after the document parsing has ended.  note that this
                  is always called, even if an error occurs.
        !*/</font>

        <font color='#0000FF'>virtual</font> <font color='#0000FF'><u>void</u></font> <b><a name='start_element'></a>start_element</b> <font face='Lucida Console'>(</font> 
            <font color='#0000FF'>const</font> <font color='#0000FF'><u>unsigned</u></font> <font color='#0000FF'><u>long</u></font> line_number,
            <font color='#0000FF'>const</font> std::string<font color='#5555FF'>&amp;</font> name,
            <font color='#0000FF'>const</font> dlib::attribute_list<font color='#5555FF'>&amp;</font> atts
        <font face='Lucida Console'>)</font><font color='#5555FF'>=</font><font color='#979000'>0</font>;
        <font color='#009900'>/*!
            requires
                - is called when an opening element tag is encountered.
                - line_number == the line number where the opening tag for this element 
                  was encountered.
                - name == the name of the element encountered 
                - atts == a list containing all the attributes in this element and their 
                  associated values
        !*/</font>

        <font color='#0000FF'>virtual</font> <font color='#0000FF'><u>void</u></font> <b><a name='end_element'></a>end_element</b> <font face='Lucida Console'>(</font> 
            <font color='#0000FF'>const</font> <font color='#0000FF'><u>unsigned</u></font> <font color='#0000FF'><u>long</u></font> line_number,
            <font color='#0000FF'>const</font> std::string<font color='#5555FF'>&amp;</font> name
        <font face='Lucida Console'>)</font><font color='#5555FF'>=</font><font color='#979000'>0</font>;
        <font color='#009900'>/*!
            requires
                - is called when a closing element tag is encountered. (note that this
                  includes tags such as &lt;example_tag/&gt;.  I.e. the previous tag would
                  trigger a start_element() callback as well as an end_element() callback)
                - line_number == the line number where the closing tag for this 
                  element was encountered and
                - name == the name of the element encountered
        !*/</font>

        <font color='#0000FF'>virtual</font> <font color='#0000FF'><u>void</u></font> <b><a name='characters'></a>characters</b> <font face='Lucida Console'>(</font> 
            <font color='#0000FF'>const</font> std::string<font color='#5555FF'>&amp;</font> data
        <font face='Lucida Console'>)</font><font color='#5555FF'>=</font><font color='#979000'>0</font>;
        <font color='#009900'>/*!
            requires
                - is called just before we encounter a start_element, end_element, or 
                  processing_instruction tag but only if there was data between the 
                  last and next tag.  
                  (i.e. data will never be "")
                - data == all the normal non-markup data and CDATA between the next and
                  last tag in the document.  
        !*/</font>

        <font color='#0000FF'>virtual</font> <font color='#0000FF'><u>void</u></font> <b><a name='processing_instruction'></a>processing_instruction</b> <font face='Lucida Console'>(</font>
            <font color='#0000FF'>const</font> <font color='#0000FF'><u>unsigned</u></font> <font color='#0000FF'><u>long</u></font> line_number,
            <font color='#0000FF'>const</font> std::string<font color='#5555FF'>&amp;</font> target,
            <font color='#0000FF'>const</font> std::string<font color='#5555FF'>&amp;</font> data
        <font face='Lucida Console'>)</font><font color='#5555FF'>=</font><font color='#979000'>0</font>;
        <font color='#009900'>/*!
            requires
                - is called when a processing instruction is encountered
                - line_number == the line number where this processing instruction
                  was encountered 
                - target == the target value for this processing instruction 
                - data == the data value for this processing instruction
        !*/</font>

    <font color='#0000FF'>protected</font>:

        <font color='#009900'>// restricted functions
</font>        document_handler<font color='#5555FF'>&amp;</font> <b><a name='operator'></a>operator</b><font color='#5555FF'>=</font><font face='Lucida Console'>(</font>document_handler<font color='#5555FF'>&amp;</font><font face='Lucida Console'>)</font> <b>{</b> <font color='#0000FF'>return</font> <font color='#5555FF'>*</font><font color='#0000FF'>this</font>; <b>}</b>
    <b>}</b>;


<font color='#009900'>// ----------------------------------------------------------------------------------------
</font><font color='#009900'>// ----------------------------------------------------------------------------------------
</font><font color='#009900'>// ----------------------------------------------------------------------------------------
</font>
    <font color='#0000FF'>class</font> <b><a name='error_handler'></a>error_handler</b>
    <b>{</b>
        <font color='#009900'>/*!                
            EXCEPTIONS
                an error_handler is allowed to throw any exception


            WHAT THIS OBJECT REPRESENTS
                this object is an interface for handling the error/warning
                events generated by an XML parser
        !*/</font>

    <font color='#0000FF'>public</font>:

        <font color='#0000FF'>inline</font> <font color='#0000FF'>virtual</font> ~<b><a name='error_handler'></a>error_handler</b> <font face='Lucida Console'>(</font>
        <font face='Lucida Console'>)</font> <font color='#5555FF'>=</font><font color='#979000'>0</font>;

        <font color='#0000FF'>virtual</font> <font color='#0000FF'><u>void</u></font> <b><a name='error'></a>error</b> <font face='Lucida Console'>(</font>
            <font color='#0000FF'>const</font> <font color='#0000FF'><u>unsigned</u></font> <font color='#0000FF'><u>long</u></font> line_number
        <font face='Lucida Console'>)</font><font color='#5555FF'>=</font><font color='#979000'>0</font>;
        <font color='#009900'>/*!
            requires
                - is called when an error that does NOT require the parser to halt
                  is encountered. (i.e. somewhat minor errors in the input)
                - line_number == the line number where this error was encountered

            the following events trigger an error:
                an invalid processing instruction
        !*/</font>

        <font color='#0000FF'>virtual</font> <font color='#0000FF'><u>void</u></font> <b><a name='fatal_error'></a>fatal_error</b> <font face='Lucida Console'>(</font>
            <font color='#0000FF'>const</font> <font color='#0000FF'><u>unsigned</u></font> <font color='#0000FF'><u>long</u></font> line_number
        <font face='Lucida Console'>)</font><font color='#5555FF'>=</font><font color='#979000'>0</font>;
        <font color='#009900'>/*!
            requires
                - is called when an error that requires the parser to abort its parsing
                  is encountered (i.e. fatal errors in the input) 
                - line_number == the line number where this fatal error was encountered

            the following events trigger a fatal_error:
                Everything other than the events listed above for error. 
                Also note that encountering an entity reference other than the 
                predefined ones listed in xml_parser_kernel_abstract is a fatal_error.
                Hitting EOF before the closing tag for the document is also a fatal_error.
        !*/</font>

    <font color='#0000FF'>protected</font>:

        <font color='#009900'>// restricted functions
</font>        error_handler<font color='#5555FF'>&amp;</font> <b><a name='operator'></a>operator</b><font color='#5555FF'>=</font><font face='Lucida Console'>(</font>error_handler<font color='#5555FF'>&amp;</font><font face='Lucida Console'>)</font> <b>{</b> <font color='#0000FF'>return</font> <font color='#5555FF'>*</font><font color='#0000FF'>this</font>;<b>}</b>
    <b>}</b>;

<font color='#009900'>// ----------------------------------------------------------------------------------------
</font><font color='#009900'>// ----------------------------------------------------------------------------------------
</font><font color='#009900'>// ----------------------------------------------------------------------------------------
</font>
    document_handler::~<b><a name='document_handler'></a>document_handler</b> <font face='Lucida Console'>(</font>
    <font face='Lucida Console'>)</font><b>{</b><b>}</b>
    attribute_list::~<b><a name='attribute_list'></a>attribute_list</b> <font face='Lucida Console'>(</font>
    <font face='Lucida Console'>)</font><b>{</b><b>}</b>
    error_handler::~<b><a name='error_handler'></a>error_handler</b> <font face='Lucida Console'>(</font>
    <font face='Lucida Console'>)</font><b>{</b><b>}</b>

<b>}</b>

<font color='#0000FF'>#endif</font> <font color='#009900'>// DLIB_XML_PARSER_KERNEl_INTERFACES_
</font>

</pre></body></html>